package com.jlnx.controller.bank;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.jlnx.dao.ChainEnterpriseDaoImpl;
import com.jlnx.dao.CoreEnterpriseDaoImpl;
import com.jlnx.dao.EnterpriseDaoImpl;
import com.jlnx.dao.FinanceReqDaoImpl;
import com.jlnx.pojo.ChainEnterprise;
import com.jlnx.pojo.CoreEnterprise;
import com.jlnx.pojo.Enterprise;
import com.jlnx.pojo.FinanceReq;


@WebServlet("/SearchEntByEntNoController")
public class SearchEntByEntNoController extends HttpServlet {
	
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		this.doPost(request, response);
	}


	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

		//获取请求信息
		response.setContentType("application/json;charset=UTF-8;text/html");
		//设置请求编码模式
    	request.setCharacterEncoding("utf-8");
				
    	String entNo = request.getParameter("entNo");
    	int role = Integer.parseInt(request.getParameter("role"));
    	
		 CoreEnterpriseDaoImpl coredao = new CoreEnterpriseDaoImpl();
		 ChainEnterpriseDaoImpl chaindao = new ChainEnterpriseDaoImpl();

		 if(role == 1) {
			 CoreEnterprise coreEnterprise = coredao.selectByEntNo(entNo);
			 request.setAttribute("Enterprise", coreEnterprise);
			 request.getRequestDispatcher("/main/entByEntNoSearch.jsp").forward(request, response);
		 }else if(role == 3) {
			 ChainEnterprise chainEnterprise = chaindao.selectByEntNo(entNo);
			 request.setAttribute("Enterprise", chainEnterprise);
			 request.getRequestDispatcher("/main/entByEntNoSearch.jsp").forward(request, response);
		 }
				
	}

}
